<template>
	<view>
		<view class="comment" v-for="(res, index) in yuepaiList">
			<u-modal v-model="show" :show-cancel-button="true" :content="content" @confirm="confirm" @cancel="cancel"></u-modal>
			<view class="left" @click="userinfo(res)">
				<image :src="res.p_ava" mode="aspectFill"></image>
			</view>
			<view class="right">
				<view class="top">
					<view class="name">{{ res.p_name }}
						<u-icon v-if="res.p_gender == '男'" size="40" name="../../../static/boy.png"></u-icon>
						<u-icon v-if="res.p_gender == '女'" size="40" name="../../../static/girl.png"></u-icon>
					</view>
					<view class="identity">{{res.identity}}</view>
				</view>
				<view class="title">{{res.title}}·{{res.payment}}
					<view>
						<u-button type="error" size="mini" shape="circle" @click="shanchu(res.id)">删除</u-button>
					</view>
				</view>
				<view class="content" @click="console(res)">
					{{ res.content }}</view>
				<view class="reply-box">
					<view style="margin-top: 20upx;display: grid;">
						<scroll-view scroll-x="true" class="pic" style="width: 100%;overflow:hidden;white-space:nowrap;">
							<image @click="previewImage(index1,res.urls)" v-for="(res1, index1) in res.urls" :src="res1" mode="aspectFill"
							 style="width:220rpx;height:220rpx;margin-bottom: 10rpx;margin-right: 10rpx;"></image>
						</scroll-view>
					</view>
				</view>
				<view class="bottom">
					<view class="time">{{res.pub_date}}
						<view style="margin-top: 10rpx;display: flex;">
							<view class="tip" style="margin-left: 10rpx;" v-for="(inss,indess) in res.p_tags">
								<u-tag class="tag" shape="circle" :text="inss" mode="plain" />
							</view>
						</view>
					</view>

				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '@/api/api.js'
	export default {
		data() {
			return {
				u_id: '',
				yuepaiList: [],
				y_id:'',
				show:false,
				content:'您确认要删除该内容吗？'
			}
		},
		onLoad(res) {
			this.u_id = res.id;
			this.getYuepai();

		},
		methods: {
			shanchu(res){
				this.y_id = res
				this.show = true;
			},
			confirm(){
				//let that = this;
				uni.request({
					url:api.baseUrl+'/delyuepai',
					method:'GET',
					data:{
						y_id:this.y_id
					},
				})
				this.getYuepai();
			},
			cancel(){
				uni.showToast({
					title:'您已取消！'
				})
			},
			previewImage(current, photos) {
				uni.previewImage({
					current,
					urls: photos
				})
			},
			userinfo(res) {
				uni.navigateTo({
					url: '../user/userinfo/userinfo?u_id=' + res.p_id
				})
			},
			//点击详情页
			console(res) {
				uni.navigateTo({
					url: './detail/detail?id=' + res.id
				})
			},
			//发布

			//读取约拍动态
			getYuepai() {
				uni.showLoading({
					title: '加载中'
				})
				uni.request({
					url: api.baseUrl+'/mineyuepai',
					method: 'GET',
					data: {
						openid: this.u_id
					},
					success: (res) => {
						//console.log(res.data)
						this.yuepaiList = res.data
						uni.hideLoading()
					}
				})
			},



		}

	}
</script>

<style lang="scss" scoped>
	.comment {
		display: flex;
		padding: 30rpx;

		.pic {
			.img_wrapper {
				width: 220upx;
				height: 150upx;
				margin-right: 15upx;
				display: inline-block;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.left {
			image {
				width: 64rpx;
				height: 64rpx;
				border-radius: 50%;
				background-color: #f2f2f2;
			}
		}

		.right {
			flex: 1;
			padding-left: 20rpx;
			font-size: 30rpx;

			.title {
				margin-bottom: 20rpx;
				margin-top: 15rpx;
				font-size: 35rpx;
				color: gray;
				display: flex;
				justify-content: space-between;
			}

			.top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-bottom: 10rpx;

				.name {
					color: #5677fc;
				}

				.like {
					display: flex;
					align-items: center;
					color: #9a9a9a;
					font-size: 26rpx;

					.num {
						margin-right: 4rpx;
						color: #9a9a9a;
					}
				}

				.highlight {
					color: #5677fc;

					.num {
						color: #5677fc;
					}
				}
			}

			.content {
				margin-bottom: 10rpx;
			}

			.reply-box {
				//background-color: rgb(242, 242, 242);
				//border-radius: 12rpx;

				.item {
					padding: 20rpx;
					border-bottom: solid 2rpx $u-border-color;

					.username {
						font-size: 24rpx;
						color: #999999;
					}
				}

				.all-reply {
					padding: 20rpx;
					display: flex;
					color: #5677fc;
					align-items: center;

					.more {
						margin-left: 6rpx;
					}
				}
			}

			.test {
				float: left;
				padding: 15rpx;
			}

			.img {
				display: flex;
			}

			.bottom {
				//margin-top: 20rpx;
				display: flex;
				font-size: 24rpx;
				color: #9a9a9a;

				.reply {
					color: #5677fc;
					margin-left: 10rpx;
				}
			}
		}
	}
</style>
